package com.education.wisdom.controller;


import com.education.common.pojo.AjaxResult;
import com.education.common.utils.ApiReturnObject;
import com.education.common.utils.StringUtils;
import com.education.wisdom.pojo.JrProfeUser;
import com.education.wisdom.service.JrProfeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.education.common.core.BaseController.writeJSON;


/**
 * 专业课程体系课程收藏表
 *
 * @date 2021-03-04 15:45:19
 */
@RestController
@RequestMapping("/wisdom/jrprofeuser")
public class JrProfeUserController {

    @Autowired
    private JrProfeUserService jrProfeUserService;

    //添加数据
    @PostMapping("/like")
    public ApiReturnObject insert(@RequestBody JrProfeUser jrProfeUser){
        List<JrProfeUser> jrProfeUsers = jrProfeUserService.selectJrProfeUserList(jrProfeUser);
        if (StringUtils.isEmpty(jrProfeUsers)){
            int i = jrProfeUserService.insertJrProfeUser(jrProfeUser);
            return new ApiReturnObject("200", "success", "收藏成功");
        }else {
            int i = jrProfeUserService.deleteJrProfeUserByIds(jrProfeUser);
            return new ApiReturnObject("200", "success", "取消收藏成功");
        }
    }

}
